#!/usr/bin/env python3.9
# -*- encoding: utf-8 -*-
"""
@文件        :serializers.py
@说明        :证件照序列化器
@时间        :2022/11/30 08:22:42
@作者        :Mars
@版本        :1.0
"""

from rest_framework import serializers

from .models import Background, Category, IDPhoto


class BackgroundSerializer(serializers.ModelSerializer):
    """背景颜色模型序列化器"""

    class Meta:
        model = Background
        fields = ("id", "name", "primary_color", "secondary_color")


class IDPhotoSerializer(serializers.ModelSerializer):
    """证件照尺寸序列化器"""

    class Meta:
        model = IDPhoto
        exclude = ("create_time", "update_time")


class CategorySerializer(serializers.ModelSerializer):
    """证件照类型序列化器"""

    photos = IDPhotoSerializer(read_only=True, many=True)

    class Meta:
        model = Category
        fields = ("id", "name", "desc", "photos")
        depth = 1
